package com.xf.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xf.common.core.domain.Constants;
import com.xf.common.core.entity.dmp.DmpAuthResource;
import com.xf.common.core.entity.dmp.DmpAuthResourceRole;
import com.xf.common.core.enums.UserCacheKeyEnum;
import com.xf.common.redis.cache.DmpRedisCache;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.xf.mapper.DmpAuthResourceMapper;
import com.xf.service.DmpAuthResourceService;

import java.time.Duration;
import java.util.List;

/**
 * @author JoeyLiu
 * @create 2022-04-20 16:31
 */
@Service
public class DmpAuthResourceServiceImpl extends ServiceImpl<DmpAuthResourceMapper, DmpAuthResource> implements DmpAuthResourceService {

    @Resource
    private DmpAuthResourceMapper dmpAuthResourceMapper;

    @Resource
    private DmpRedisCache redisCache;

    @Override
    public List<DmpAuthResourceRole> getAllResourceRole() {
        return redisCache.getEx(UserCacheKeyEnum.RESOURCE.getKey("ALL"),
                Duration.ofSeconds(Constants.USER_TIME_OUT), () -> dmpAuthResourceMapper.getallResourceRole());


    }

}



